# 导入库
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.neighbors import KNeighborsClassifier

# 利用load_iris读取鸢尾花数据集（sklearn.datasets）
iris = load_iris()

# 使用train_test_split函数切分训练集和测试集，测试集占25%，随机数种子为33
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.25, random_state=33)

# 对训练集和测试集做标准化处理（提示：Standard....）
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)

# 利用K近邻分类器对测试数据进行类别预测，预测结果存储在变量y_predict中（提示：Kneighbor...）
knn = KNeighborsClassifier()
knn.fit(X_train, y_train)
y_predict = knn.predict(X_test)

# 测试与性能评估
from sklearn.metrics import accuracy_score, classification_report
print("准确率：", accuracy_score(y_test, y_predict))
print("分类报告：\n", classification_report(y_test, y_predict))